
// ECharts绘制对象
var option = null;

//颜色,暂定5个
const color = ["gold", "red", "yellow", "orange", "white"];

/**
 * 封装数据
 */
function forData(optionJson) {
    // 样例值
    var res = [
            [[112.09988, 32.70335],[112.1269, 32.6976]],
            [[112.1269, 32.6976],[112.10888, 32.6626]],
            [[112.10888, 32.6626],[112.0409, 32.6434]]
    ];

    if(optionJson!=null) {
        res = [];
        res = JSON.parse(optionJson);
    }

    // 设置颜色随机选择(5个颜色)
    var randomNum = Math.random()*5;

    option = {
        baseOption: {
            bmap: bmap,

            geo: {
                map: 'bmap',
                roam:true
            },

            series: [
                {
                    type: 'lines',
                    coordinateSystem: 'bmap',

                    lineStyle: {
                        normal: {
                            color: color[parseInt(randomNum,10)],
                            width: 2,
                            opacity: 0.8, //图形透明度。支持从 0 到 1 的数字，为 0 时不绘制该图形。
                            curveness: 0.1 //边的曲度，支持从 0 到 1 的值，值越大曲度越大
                        }
                    },
                    data: res
                }
            ]
        }
    };
}

function getOption(optionJson) {
     forData(optionJson);
    return this.option;
}